
package br.unipampa.utilitarios;

import br.unipampa.dados.DBConection;
import br.unipampa.view.ApoioDeInterface;
import com.mysql.jdbc.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Gabriel Moro
 * @since 15/03/2013
 * @version 1.2
 */
public class TestarConexao {
    
    private DBConection con;
    private Statement stm;
    private ResultSet rs;
    
        public boolean testarConexaoComBanco() {
        try {
            this.con = new DBConection();
            this.stm= (Statement) this.con.getCon().createStatement();
           this.rs= stm.executeQuery("show tables;");
            if(this.rs.next()){
                return true;
            }else{
                return false;
            }
        } catch (SQLException erroSQL) {
            ApoioDeInterface.mensagemErroBanco(erroSQL.getMessage());
            System.exit(0);
        } finally {
            this.con.encerrarConexao();
        }
        return false;
    }
}
